package com.hjqjl.module_mine.ui.activity;

import android.content.Context;
import android.content.Intent;
import android.widget.CompoundButton;

import com.blankj.utilcode.util.ToastUtils;
import com.hjqjl.module_mine.databinding.MineActivitySetBinding;
import com.hjqjl.whapplib.base.BaseActivity;
import com.hjqjl.whapplib.utils.SPManager;

public class SetActivity extends BaseActivity<MineActivitySetBinding> {
    public static void start(Context context) {
        Intent starter = new Intent(context, SetActivity.class);
        context.startActivity(starter);
    }

    @Override
    public void initData() {
        setTitle("设置");
        if (SPManager.hasBlackWhite()) {
            pVBinding.mineSwSetBlackWhite.setChecked(true);
        } else {
            pVBinding.mineSwSetBlackWhite.setChecked(false);
        }
    }

    @Override
    public void initListener() {
        pVBinding.mineSwSetBlackWhite.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    SPManager.SP.put(SPManager.KEY_BLACK_WHITE, true);
                    ToastUtils.showShort("打开黑白屏");
                } else {
                    SPManager.SP.put(SPManager.KEY_BLACK_WHITE, false);
                    ToastUtils.showShort("关闭黑白屏,需重新打开Activity");
                }
            }
        });
    }


}
